package geo.campus;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.widget.Button;
import android.widget.Toast;

public class Geocampusactivity extends Activity {

	private Button carte;
	private int CODE_RET_OPT = 1;

	/** Called when the activity is first created. */
	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.main);


		carte = (Button) findViewById(R.id.btcarte);
		final Activity act = this;

		carte.setOnClickListener(new View.OnClickListener() {

			public void onClick(View v) {
				// TODO Auto-generated method stub
				Intent page = new Intent(act, Map.class);
				act.startActivity(page);
			}
		});
	}	

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// TODO Auto-generated method stub
		MenuInflater inflater = getMenuInflater();
		inflater.inflate(R.menu.menu1, menu);
		return super.onCreateOptionsMenu(menu);
	}

	@Override
	public boolean onOptionsItemSelected(MenuItem item) {
		// TODO Auto-generated method stub

		switch (item.getItemId()) {
		case R.id.menu_info1:
			Toast.makeText(this, "Hello world!", Toast.LENGTH_SHORT).show();
			return true;
		case R.id.menu_preferences1:
			startActivityForResult(new Intent(this, Preferences.class), CODE_RET_OPT);
			return true;
		default:
			return super.onOptionsItemSelected(item);
		}

	}
	
	protected void onActivityResult(int ident, int code_retour, Intent retour)
	{
		if(ident == CODE_RET_OPT)
		{
			Toast.makeText(this, "Modifications terminées", Toast.LENGTH_SHORT).show();
		}
		super.onActivityResult(ident, code_retour, retour);
	}

}